package org.walkerljl.practice.mock.mockito;

import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.walkerljl.practice.mock.dao.UserDao;
import org.walkerljl.practice.mock.domain.User;
import org.walkerljl.practice.mock.service.UserService;
import org.walkerljl.practice.mock.service.impl.UserServiceImpl;

/**
 * @author: lijunlin
 */
public class UserServiceTest extends BaseTest {

    @Mock
    private UserDao userDao;

    @InjectMocks
    private UserService userService = new UserServiceImpl();

    @Test
    public void register() {
        Mockito.when(userDao.selectByUserId(Mockito.anyString()))
                .thenReturn(new User("zhangsan", "张三"));
        userService.register(new User("lijunlin", "lijunlin"));
    }
}


